#include "Material.h"

Material::Material( float mE[4], float mA[4], float mD[4], float mS[4], float shi[1], bool inh)
{
	this->inherit=inh;
	if(!inh){
		setEmission(mE);
		setAmbient(mA);
		setDiffuse(mD);
		setSpecular(mS);
		setShininess(shi);
	}
}

float* Material::getEmission()
{
	return mEmission;
}

float* Material::getAmbient()
{
	return mAmbient;
}

float* Material::getDiffuse()
{
	return mDiffuse;
}

float* Material::getSpecular()
{
	return mSpecular;
}

float* Material::getShininess()
{
	return mShininess;
}

void Material::setEmission(float a[4])
{
	mEmission[0]=a[0];
	mEmission[1]=a[1];
	mEmission[2]=a[2];
	mEmission[3]=a[3];
}

void Material::setAmbient(float a[4])
{
	mAmbient[0]=a[0];
	mAmbient[1]=a[1];
	mAmbient[2]=a[2];
	mAmbient[3]=a[3];
}

void Material::setDiffuse(float a[4])
{
	mDiffuse[0]=a[0];
	mDiffuse[1]=a[1];
	mDiffuse[2]=a[2];
	mDiffuse[3]=a[3];
}

void Material::setSpecular(float a[4])
{
	mSpecular[0]=a[0];
	mSpecular[1]=a[1];
	mSpecular[2]=a[2];
	mSpecular[3]=a[3];
}

void Material::setShininess(float a[1])
{
	mShininess[0]=a[0];
}

void Material::act()
{
	if(!this->inherit){
		glMaterialfv(GL_FRONT, GL_SHININESS, mShininess);
		glMaterialfv(GL_FRONT, GL_SPECULAR,  mSpecular);
		glMaterialfv(GL_FRONT, GL_DIFFUSE,   mDiffuse);
		glMaterialfv(GL_FRONT, GL_AMBIENT,   mAmbient);
		glMaterialfv(GL_FRONT, GL_EMISSION,  mEmission);
	}
}
